package yxy.game.pm2.command.shop;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.ShopMessage;
import yxy.game.pm2.module.shop.handle.UnionWarShopHandle;

/** 商店 联盟战商店 */
@MessageType(proto = Command.UnionWarShop, classtype = ShopMessage.UnionWarShopRequest.class)
public class CMD_UnionWarShop extends Command<ShopMessage.UnionWarShopRequest> {

	@Override
	public void execute(MessageSource messageSource, ShopMessage.UnionWarShopRequest request) {
		String playerCode = messageSource.getTag();

		ShopMessage.UnionWarShopResponse.Builder response = ShopMessage.UnionWarShopResponse.newBuilder();

		response.addAllGoods(new UnionWarShopHandle().goods(playerCode));

		send(messageSource, response, Result.Success);
	}

	private void send(MessageSource messageSource, ShopMessage.UnionWarShopResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}